package com.taijihuabao.modules.enums.optenums.checkin;

/**
 * 打卡状态枚举
 *
 * @author Tu
 * @date 2022/1/5 10:26
 */
public enum CheckInStatusEnum {

    /**
     * 正常
     */
    Normal("1", "正常"),
    /**
     * 迟到
     */
    Late("2", "迟到"),
    /**
     * 严重迟到
     */
    LateSeverity("3", "严重迟到"),
    /**
     * 旷工
     */
    Absenteeism("4", "旷工"),
    /**
     * 早退
     */
    LeaveEarly("5", "早退"),
    /**
     * 缺卡
     */
    LackCard("6", "早退");


    private final String code;
    private final String message;

    CheckInStatusEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据状态code获取枚举名称
     *
     * @return
     */
    public static String getMessageByCode(String code) {
        for (CheckInStatusEnum status : CheckInStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status.message;
            }
        }
        return null;
    }

    /**
     * 根据状态code获取枚举值
     *
     * @return
     */
    public static CheckInStatusEnum getByCode(String code) {
        for (CheckInStatusEnum status : CheckInStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
